home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 1.6 KB | 85 lines | [TEXT/MPS ] |
- (*
- ticksToHMS() -- Convert from HMS format to 1/60ths of a second
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w ticksToHMS.p
-
- link -m ENTRYPOINT -o HyperCommands -rt XFCN=8001 -sn Main=ticksToHMS ∂
- ticksToHMS.p.o "{MPW}"PLibraries:PasLib.o
-
- Copyright © 1988 Apple Computer, Inc.
-
- 2/88 - Initial coding by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S ticksToHMS } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- type
-
- Str31 = String[31];
-
- procedure ticksToHMS(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- ticksToHMS(paramPtr);
- end;
-
- procedure ticksToHMS(paramPtr: XCmdPtr);
-
- var t: longInt;
- result: str255;
-
- {$I XCmdGlue.inc}
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(errMsg);
- exit(ticksToHMS);
- end;
-
- {$I VideoUtil.inc}
-
- procedure doDigits(value: longInt; index: integer);
-
- var str: str255;
- c1, c2: char;
-
- begin
- str := LongToStr(value);
- if length(str) < 2 then c1 := '0'
- else c1 := str[length(str)-1];
- if length(str) < 1 then c2 := '0'
- else c2 := str[length(str)];
- result[index] := c1;
- result[index+1] := c2;
- end;
-
- begin
- if paramPtr^.paramCount <> 1 then Fail('parameter count is not 1');
-
- result := 'xxxxxx';
- t := GetLongParm(1);
- doDigits((t div 216000) mod 100,1);
- doDigits((t div 3600) mod 60,3);
- doDigits((t div 60) mod 60,5);
-
- paramPtr^.returnValue := PasToZero(result);
- end;
-
- end.
-